package com.zhida.smartcontrol.pagectrl.projectdetail.warning;

import android.view.View;

import androidx.annotation.Nullable;

import com.jay.tools.recycler.MultipleViewHolder;
import com.jay.tools.recycler.SingleRecyclerAdapter;
import com.jay.tools.ui.ButtonStyle;
import com.zhida.smartcontrol.R;
import com.zhida.smartcontrol.common.bean.LampBean;
import com.zhida.smartcontrol.pagectrl.projectdetail.zonemanager.JkqAdapter;

import java.util.List;

/**
 * author: tanjianpei
 * date: 2019/10/11 011 10:38
 * description:
 */
public class WarningAdapter extends SingleRecyclerAdapter<WarningBean.ListBean.RecordsBean> {
    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    private String projectName = "";

    public WarningAdapter(@Nullable List<WarningBean.ListBean.RecordsBean> data) {
        super(R.layout.item_warning, data);
    }

    @Override
    protected void convert(MultipleViewHolder holder, WarningBean.ListBean.RecordsBean info) {
        holder.setText(R.id.tv_address, info.getAddress()).setText(R.id.tv_type, info.getAlarmTypeTxt())
                .setText(R.id.tv_imei, "设备IMEI：" + info.getImei()).setText(R.id.tv_time, info.getEventTime())
                .setText(R.id.tv_xiangmu, projectName).setText(R.id.tv_guzhang, info.getStatusTxt());
        ButtonStyle btnEdit = holder.getView(R.id.btn_edit);
        ButtonStyle btnDel = holder.getView(R.id.btn_del);
        btnEdit.setOnClickListener(new ClickListener(info, 0));

        btnDel.setOnClickListener(new ClickListener(info, 1));
    }
    private class ClickListener implements View.OnClickListener {
        private WarningBean.ListBean.RecordsBean mInfo;
        private int mClickId;

        public ClickListener(WarningBean.ListBean.RecordsBean mInfo, int mClickId) {
            this.mInfo = mInfo;
            this.mClickId = mClickId;
        }

        @Override
        public void onClick(View v) {
            if (null != mListener) {
                mListener.onClick(mInfo, mClickId);
            }
        }
    }
}
